// api/user_api/user_options.go
package user_api

import (
	"github.com/gin-gonic/gin"
	"muziai-server/global"
	"muziai-server/models"
	"muziai-server/models/ctype"
	"muziai-server/utils/res"
)

type UserOptionsRequest struct {
	Nickname string     `json:"nickname" form:"nickname"`
	Role     ctype.Role `json:"role" form:"role"`
}

func (UserApi) UserOptionsView(c *gin.Context) {
	var list []models.Options[uint]
	var cr UserOptionsRequest
	c.ShouldBindQuery(&cr)
	global.DB.Model(models.UserModel{}).Where(models.UserModel{Nickname: cr.Nickname, Role: cr.Role}).
		Select("nickname as label", "id as value").Scan(&list)
	res.OkWithData(c, list)
	return
}
